<?php

class PublicationResource {
	private $id;
	private $publication;
	private $resource;
	
	function __construct($id,$publication, $resource){
		$this -> id = $id;
		$this -> publication = $publication;
		$this -> resource = $resource;
	}
	
	function getComment($db,$id){
		$result=$db->query("SELECT * FROM publication_resource WHERE pr_IDresource = $id",2);
		$publicationResource=new PublicationResource($result[0]['pr_IDresource'], 
													$result[0]['pr_id_publication'],
													$result[0]['pr_id_resource']);
				
		return $publicationResource;
	
	}
	
	function insertComment($db,$publicationResource){
		$publication 	= $publicationResource -> getPublication();
		$resource		= $publicationResource -> getResource();
		$result=$db->insert("INSERT INTO publication_resource (pr_id_publication, pr_id_resource)
										 VALUES($publication,$resource");
		return $result;
	}	
	
	function deleteComment($db,$publicationResource){
		$id 			= $publicationResource -> getID();
		$result=$db->delete("DELETE FROM publication_resource WHERE pr_IDresource = " . $id);
		return $result;
	}	
	
	function updateComment($db,$publicationResource){
		$id 			= $publicationResource -> getID();
		$resource 		= $publicationResource -> getResource();
		$publication	= $publicationResource -> getPublication();
		$result=$db->update("UPDATE publication_resource SET pr_id_publication=$publication, pr_id_resource=$resource WHERE pr_IDresource = ".$id);
		return $result;
	}		
	
	
	
	function getResource(){
		return $this -> resource;
	}	
	
	function  setResource($resource){
		$this -> resource = $resource;
	}	

	
	function getPublication(){
		return $this -> publication;
	}
	
	function  setPublication($publication){
		$this -> publication = $publication;
	}	
	
	function getID(){
		return $this -> id;
	}
	
	function  setID($id){
		$this -> id = $id;
	}
}

?>